/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.money.dao.impl;

import com.money.dao.ArticleDao;
import com.money.entity.Article;
import com.money.mapper.ArticleMapper;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Repository;

/**
 *
 * @author Eason
 */
@SuppressWarnings("unchecked")
@Repository("ariticleDao") 
public class ArticleDaoImpl <T extends Article> implements ArticleDao<T>{
    
    @Resource(name="articleMapper")
    private ArticleMapper mapper;
    
    @Override
    public boolean addArticle(T entity) throws DataAccessException{
        boolean flag = false;
        try{
            mapper.addArticle(entity);
            flag = true;
        }catch(DataAccessException e){
            flag = false;
            throw e; 
        }
        return flag;
    }

    @Override
    public boolean editArticle(T entity) throws DataAccessException {
        boolean flag = false;
        try{
            mapper.editAriticle(entity);
            flag = true;
        }catch(DataAccessException e){
            flag = false;
            throw e; 
        }
        return flag;
    }

    @Override
    public boolean removeArticle(int id) throws DataAccessException {
        boolean flag = false;
        try{
            mapper.removeArticle(id);
            flag = true;
        }catch(DataAccessException e){
            flag = false;
            throw e; 
        }
        return flag;
    }

    @Override
    public List<T> getAllArticle() throws DataAccessException {
      
        return (List<T>)mapper.getAllArticle();
    }
  
}
